{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "患病样本基因组数据文件总数: 7\n",
      "正常样本基因组数据文件总数: 11\n",
      "总样本基因组数据文件数: 18\n",
      "患病样本文件名 ['Base-data/AD\\\\006_S_4153.csv', 'Base-data/AD\\\\006_S_4192.csv', 'Base-data/AD\\\\018_S_4733.csv', 'Base-data/AD\\\\019_S_4252.csv', 'Base-data/AD\\\\019_S_4477.csv', 'Base-data/AD\\\\019_S_5012.csv', 'Base-data/AD\\\\019_S_5019.csv']\n",
      "正常样本文件名 ['Base-data/HC\\\\002_S_4213.csv', 'Base-data/HC\\\\002_S_4225.csv', 'Base-data/HC\\\\002_S_4262.csv', 'Base-data/HC\\\\002_S_4264.csv', 'Base-data/HC\\\\002_S_4270.csv', 'Base-data/HC\\\\006_S_4150.csv', 'Base-data/HC\\\\006_S_4357.csv', 'Base-data/HC\\\\006_S_4449.csv', 'Base-data/HC\\\\006_S_4485.csv', 'Base-data/HC\\\\012_S_4026.csv', 'Base-data/HC\\\\013_S_4579.csv']\n",
      "总样本文件名 ['006_S_4153', '006_S_4192', '018_S_4733', '019_S_4252', '019_S_4477', '019_S_5012', '019_S_5019', '002_S_4213', '002_S_4225', '002_S_4262', '002_S_4264', '002_S_4270', '006_S_4150', '006_S_4357', '006_S_4449', '006_S_4485', '012_S_4026', '013_S_4579']\n"
     ]
    }
   ],
   "source": [
    "import glob, os\n",
    "from os import getcwd\n",
    "from os import listdir\n",
    "import pandas as pd \n",
    "import numpy as np\n",
    "ad_files_num=len(os.listdir('Base-data/AD'))\n",
    "hc_files_num=len(os.listdir('Base-data/HC'))\n",
    "print(\"患病样本基因组数据文件总数:\",ad_files_num)\n",
    "print(\"正常样本基因组数据文件总数:\",hc_files_num)\n",
    "files_num=ad_files_num+hc_files_num\n",
    "print(\"总样本基因组数据文件数:\",files_num) \n",
    "adfiles = glob.glob(os.path.join('Base-data/AD/*.csv'))\n",
    "hcfiles = glob.glob(os.path.join('Base-data/HC/*.csv'))\n",
    "print (\"患病样本文件名\",adfiles)\n",
    "print (\"正常样本文件名\",hcfiles)\n",
    "allfiles = adfiles+hcfiles\n",
    "allfiles_name=[]\n",
    "for filepath in allfiles:\n",
    "    allfiles_name.append(filepath.split('.')[0].split('\\\\')[1])\n",
    "print (\"总样本文件名\",allfiles_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Sample Index</th>\n",
       "      <th>Sample ID</th>\n",
       "      <th>GC Score</th>\n",
       "      <th>SNP Index</th>\n",
       "      <th>SNP Name</th>\n",
       "      <th>Allele1 - Top</th>\n",
       "      <th>Allele2 - Top</th>\n",
       "      <th>Allele1 - Forward</th>\n",
       "      <th>Allele2 - Forward</th>\n",
       "      <th>Allele1 - AB</th>\n",
       "      <th>...</th>\n",
       "      <th>Cluster Sep</th>\n",
       "      <th>SNP</th>\n",
       "      <th>Theta</th>\n",
       "      <th>R</th>\n",
       "      <th>X</th>\n",
       "      <th>Y</th>\n",
       "      <th>X Raw</th>\n",
       "      <th>Y Raw</th>\n",
       "      <th>B Allele Freq</th>\n",
       "      <th>Log R Ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.8228</td>\n",
       "      <td>1</td>\n",
       "      <td>rs1000000</td>\n",
       "      <td>A</td>\n",
       "      <td>G</td>\n",
       "      <td>T</td>\n",
       "      <td>C</td>\n",
       "      <td>A</td>\n",
       "      <td>...</td>\n",
       "      <td>0.7954</td>\n",
       "      <td>[T/C]</td>\n",
       "      <td>0.374</td>\n",
       "      <td>2.203</td>\n",
       "      <td>1.323</td>\n",
       "      <td>0.880</td>\n",
       "      <td>7045</td>\n",
       "      <td>6376</td>\n",
       "      <td>0.4419</td>\n",
       "      <td>0.0283</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.8822</td>\n",
       "      <td>2</td>\n",
       "      <td>rs1000002</td>\n",
       "      <td>A</td>\n",
       "      <td>G</td>\n",
       "      <td>A</td>\n",
       "      <td>G</td>\n",
       "      <td>A</td>\n",
       "      <td>...</td>\n",
       "      <td>0.4683</td>\n",
       "      <td>[A/G]</td>\n",
       "      <td>0.410</td>\n",
       "      <td>1.075</td>\n",
       "      <td>0.613</td>\n",
       "      <td>0.461</td>\n",
       "      <td>3207</td>\n",
       "      <td>3301</td>\n",
       "      <td>0.4710</td>\n",
       "      <td>-0.0796</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.8360</td>\n",
       "      <td>3</td>\n",
       "      <td>rs10000023</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>T</td>\n",
       "      <td>T</td>\n",
       "      <td>A</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>[T/G]</td>\n",
       "      <td>0.017</td>\n",
       "      <td>1.870</td>\n",
       "      <td>1.821</td>\n",
       "      <td>0.050</td>\n",
       "      <td>9610</td>\n",
       "      <td>395</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.1101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.8951</td>\n",
       "      <td>4</td>\n",
       "      <td>rs1000003</td>\n",
       "      <td>A</td>\n",
       "      <td>G</td>\n",
       "      <td>A</td>\n",
       "      <td>G</td>\n",
       "      <td>A</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>[T/C]</td>\n",
       "      <td>0.499</td>\n",
       "      <td>1.130</td>\n",
       "      <td>0.566</td>\n",
       "      <td>0.564</td>\n",
       "      <td>2970</td>\n",
       "      <td>4029</td>\n",
       "      <td>0.5451</td>\n",
       "      <td>-0.2636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.6725</td>\n",
       "      <td>5</td>\n",
       "      <td>rs10000030</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>B</td>\n",
       "      <td>...</td>\n",
       "      <td>0.3985</td>\n",
       "      <td>[T/C]</td>\n",
       "      <td>0.982</td>\n",
       "      <td>0.566</td>\n",
       "      <td>0.015</td>\n",
       "      <td>0.550</td>\n",
       "      <td>99</td>\n",
       "      <td>3631</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.4046</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730520</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.5087</td>\n",
       "      <td>730521</td>\n",
       "      <td>VGXS34742</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>B</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>[T/C]</td>\n",
       "      <td>0.975</td>\n",
       "      <td>1.037</td>\n",
       "      <td>0.039</td>\n",
       "      <td>0.998</td>\n",
       "      <td>259</td>\n",
       "      <td>7206</td>\n",
       "      <td>0.9912</td>\n",
       "      <td>-0.1423</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730521</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.4016</td>\n",
       "      <td>730522</td>\n",
       "      <td>VGXS34743</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>B</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>[A/G]</td>\n",
       "      <td>0.979</td>\n",
       "      <td>1.367</td>\n",
       "      <td>0.044</td>\n",
       "      <td>1.323</td>\n",
       "      <td>311</td>\n",
       "      <td>9548</td>\n",
       "      <td>0.9982</td>\n",
       "      <td>-0.0809</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730522</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.5296</td>\n",
       "      <td>730523</td>\n",
       "      <td>VGXS34744</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>B</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>[A/G]</td>\n",
       "      <td>0.990</td>\n",
       "      <td>0.931</td>\n",
       "      <td>0.015</td>\n",
       "      <td>0.917</td>\n",
       "      <td>153</td>\n",
       "      <td>7114</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>-0.2220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730523</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.5115</td>\n",
       "      <td>730524</td>\n",
       "      <td>VGXS34761</td>\n",
       "      <td>G</td>\n",
       "      <td>G</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>B</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>[T/C]</td>\n",
       "      <td>0.959</td>\n",
       "      <td>0.970</td>\n",
       "      <td>0.059</td>\n",
       "      <td>0.911</td>\n",
       "      <td>358</td>\n",
       "      <td>6575</td>\n",
       "      <td>0.9798</td>\n",
       "      <td>-0.1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730524</th>\n",
       "      <td>273</td>\n",
       "      <td>006_S_4153</td>\n",
       "      <td>0.4817</td>\n",
       "      <td>730525</td>\n",
       "      <td>VGXS35706</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>T</td>\n",
       "      <td>T</td>\n",
       "      <td>A</td>\n",
       "      <td>...</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>[A/G]</td>\n",
       "      <td>0.021</td>\n",
       "      <td>0.621</td>\n",
       "      <td>0.601</td>\n",
       "      <td>0.020</td>\n",
       "      <td>3156</td>\n",
       "      <td>160</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.7627</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>730525 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        Sample Index   Sample ID  GC Score  SNP Index    SNP Name  \\\n",
       "0                273  006_S_4153    0.8228          1   rs1000000   \n",
       "1                273  006_S_4153    0.8822          2   rs1000002   \n",
       "2                273  006_S_4153    0.8360          3  rs10000023   \n",
       "3                273  006_S_4153    0.8951          4   rs1000003   \n",
       "4                273  006_S_4153    0.6725          5  rs10000030   \n",
       "...              ...         ...       ...        ...         ...   \n",
       "730520           273  006_S_4153    0.5087     730521   VGXS34742   \n",
       "730521           273  006_S_4153    0.4016     730522   VGXS34743   \n",
       "730522           273  006_S_4153    0.5296     730523   VGXS34744   \n",
       "730523           273  006_S_4153    0.5115     730524   VGXS34761   \n",
       "730524           273  006_S_4153    0.4817     730525   VGXS35706   \n",
       "\n",
       "       Allele1 - Top Allele2 - Top Allele1 - Forward Allele2 - Forward  \\\n",
       "0                  A             G                 T                 C   \n",
       "1                  A             G                 A                 G   \n",
       "2                  A             A                 T                 T   \n",
       "3                  A             G                 A                 G   \n",
       "4                  G             G                 G                 G   \n",
       "...              ...           ...               ...               ...   \n",
       "730520             G             G                 C                 C   \n",
       "730521             G             G                 G                 G   \n",
       "730522             G             G                 G                 G   \n",
       "730523             G             G                 C                 C   \n",
       "730524             A             A                 T                 T   \n",
       "\n",
       "       Allele1 - AB  ... Cluster Sep    SNP  Theta      R      X      Y  \\\n",
       "0                 A  ...      0.7954  [T/C]  0.374  2.203  1.323  0.880   \n",
       "1                 A  ...      0.4683  [A/G]  0.410  1.075  0.613  0.461   \n",
       "2                 A  ...      1.0000  [T/G]  0.017  1.870  1.821  0.050   \n",
       "3                 A  ...      1.0000  [T/C]  0.499  1.130  0.566  0.564   \n",
       "4                 B  ...      0.3985  [T/C]  0.982  0.566  0.015  0.550   \n",
       "...             ...  ...         ...    ...    ...    ...    ...    ...   \n",
       "730520            B  ...      1.0000  [T/C]  0.975  1.037  0.039  0.998   \n",
       "730521            B  ...      1.0000  [A/G]  0.979  1.367  0.044  1.323   \n",
       "730522            B  ...      1.0000  [A/G]  0.990  0.931  0.015  0.917   \n",
       "730523            B  ...      1.0000  [T/C]  0.959  0.970  0.059  0.911   \n",
       "730524            A  ...      1.0000  [A/G]  0.021  0.621  0.601  0.020   \n",
       "\n",
       "        X Raw Y Raw  B Allele Freq  Log R Ratio  \n",
       "0        7045  6376         0.4419       0.0283  \n",
       "1        3207  3301         0.4710      -0.0796  \n",
       "2        9610   395         0.0000      -0.1101  \n",
       "3        2970  4029         0.5451      -0.2636  \n",
       "4          99  3631         1.0000       0.4046  \n",
       "...       ...   ...            ...          ...  \n",
       "730520    259  7206         0.9912      -0.1423  \n",
       "730521    311  9548         0.9982      -0.0809  \n",
       "730522    153  7114         1.0000      -0.2220  \n",
       "730523    358  6575         0.9798      -0.1974  \n",
       "730524   3156   160         0.0000      -0.7627  \n",
       "\n",
       "[730525 rows x 26 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df =  pd.read_csv(allfiles[0],header=0,index_col=False)#从0行开始算，重新设置一列成为index值\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>染色体号</th>\n",
       "      <th>rs号</th>\n",
       "      <th>遗传距离</th>\n",
       "      <th>位置</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>12</td>\n",
       "      <td>rs1000000</td>\n",
       "      <td>0</td>\n",
       "      <td>126890980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3</td>\n",
       "      <td>rs1000002</td>\n",
       "      <td>0</td>\n",
       "      <td>183635768</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4</td>\n",
       "      <td>rs10000023</td>\n",
       "      <td>0</td>\n",
       "      <td>95733906</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>rs1000003</td>\n",
       "      <td>0</td>\n",
       "      <td>98342907</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>rs10000030</td>\n",
       "      <td>0</td>\n",
       "      <td>103374154</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730392</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999953</td>\n",
       "      <td>0</td>\n",
       "      <td>41782996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730393</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999955</td>\n",
       "      <td>0</td>\n",
       "      <td>116786795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730394</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999963</td>\n",
       "      <td>0</td>\n",
       "      <td>84072737</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730395</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999966</td>\n",
       "      <td>0</td>\n",
       "      <td>5927355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730396</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999992</td>\n",
       "      <td>0</td>\n",
       "      <td>122902084</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>730397 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       染色体号         rs号  遗传距离         位置\n",
       "0        12   rs1000000     0  126890980\n",
       "1         3   rs1000002     0  183635768\n",
       "2         4  rs10000023     0   95733906\n",
       "3         3   rs1000003     0   98342907\n",
       "4         4  rs10000030     0  103374154\n",
       "...     ...         ...   ...        ...\n",
       "730392    4   rs9999953     0   41782996\n",
       "730393    4   rs9999955     0  116786795\n",
       "730394    4   rs9999963     0   84072737\n",
       "730395    4   rs9999966     0    5927355\n",
       "730396    4   rs9999992     0  122902084\n",
       "\n",
       "[730397 rows x 4 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_map = pd.DataFrame()\n",
    "df_map['染色体号'] = df['Chr']\n",
    "df_map['rs号'] = df['SNP Name']\n",
    "df_map['遗传距离'] = 0\n",
    "df_map['位置'] = df['Position']\n",
    "df_map_out=df_map[df_map.index<730397]\n",
    "df_map_out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>染色体号</th>\n",
       "      <th>rs号</th>\n",
       "      <th>遗传距离</th>\n",
       "      <th>位置</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>12</td>\n",
       "      <td>rs1000000</td>\n",
       "      <td>0</td>\n",
       "      <td>126890980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3</td>\n",
       "      <td>rs1000002</td>\n",
       "      <td>0</td>\n",
       "      <td>183635768</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4</td>\n",
       "      <td>rs10000023</td>\n",
       "      <td>0</td>\n",
       "      <td>95733906</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>rs1000003</td>\n",
       "      <td>0</td>\n",
       "      <td>98342907</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>rs10000030</td>\n",
       "      <td>0</td>\n",
       "      <td>103374154</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730392</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999953</td>\n",
       "      <td>0</td>\n",
       "      <td>41782996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730393</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999955</td>\n",
       "      <td>0</td>\n",
       "      <td>116786795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730394</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999963</td>\n",
       "      <td>0</td>\n",
       "      <td>84072737</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730395</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999966</td>\n",
       "      <td>0</td>\n",
       "      <td>5927355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730396</th>\n",
       "      <td>4</td>\n",
       "      <td>rs9999992</td>\n",
       "      <td>0</td>\n",
       "      <td>122902084</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>730397 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       染色体号         rs号  遗传距离         位置\n",
       "0        12   rs1000000     0  126890980\n",
       "1         3   rs1000002     0  183635768\n",
       "2         4  rs10000023     0   95733906\n",
       "3         3   rs1000003     0   98342907\n",
       "4         4  rs10000030     0  103374154\n",
       "...     ...         ...   ...        ...\n",
       "730392    4   rs9999953     0   41782996\n",
       "730393    4   rs9999955     0  116786795\n",
       "730394    4   rs9999963     0   84072737\n",
       "730395    4   rs9999966     0    5927355\n",
       "730396    4   rs9999992     0  122902084\n",
       "\n",
       "[730397 rows x 4 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cllumn_name='染色体号'\n",
    "pan_x = (df_map[cllumn_name]=='X')\n",
    "pan_y = (df_map[cllumn_name]=='Y')\n",
    "pan_xy = (df_map[cllumn_name]=='XY')\n",
    "pan_mt = (df_map[cllumn_name]=='MT')\n",
    "df_map.loc[pan_x,cllumn_name] = 23\n",
    "df_map.loc[pan_y,cllumn_name] = 24\n",
    "df_map.loc[pan_xy,cllumn_name] = 25\n",
    "df_map.loc[pan_mt,cllumn_name] = 26\n",
    "df_map_out=df_map[df_map.index<730397]\n",
    "df_map_out"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 保存生成的map文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_map_out.to_csv(\"fix-data/map.csv\", index = False,header=None,sep=' ', encoding='utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
